// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Take 20 photographs with the camera.

local Value = achievements.GetValue( "Photographer", "total", 0 )

local function Update(ply, bind, pressed)

	if (Value != 20) then
		// print("Check Started.\n")
		local ply = LocalPlayer()
		local weap = ply:GetActiveWeapon()

		if (!ValidEntity( ply )) then return end
		
		if ( ValidEntity( weap ) && weap:GetClass() == "gmod_camera" && bind == "+attack" ) then

			// print("Camera Started.\n")
			Value = math.Clamp( Value + 1, 0, 20 )
			achievements.SetValue( "Photographer", "total", Value )
			achievements.Update( "Photographer", Value / 20, Value .. "/20" )
		else
			// print("Camera Ended.\n")
		end

		// print("Check Ended.\n")
	end

end

hook.Add("PlayerBindPress", "Achievement.Photographer", Update)

achievements.Register( "Photographer", "Take 20 photographs with the camera.", "achievements/photographer", Value / 20, Value .. "/20" )